//
//  Player.cpp
//  DiceWar
//
//  Created by Xiao  Feng on 19/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include "Player.h"
#include "HexMap.h"
#include "HumanPlayer.h"
#include "RobotPlayer.h"
#include "GameMaster.h"

Player::Player(PlayerType type)
: m_type(type) {}

Player::~Player() {}

PlayerType Player::getType() const
{
    return m_type;
}

int Player::getNumOccupiedCells() const
{
    const HexMap& gameMap = GameMaster::instance().getHexMap();
    return gameMap.getNumPlayerCells(m_type);
}

bool Player::isDead() const
{
    return getNumOccupiedCells() == 0;
}

bool Player::hasCell(int coordinateX, int coordinateY) const
{
    const HexMap& gameMap = GameMaster::instance().getHexMap();
    const HexMapGrid& mapGrid = gameMap.getMapGrid(coordinateX, coordinateY);
    return mapGrid.isOwnedByPlayer(m_type);
}


